﻿using Omniscient.Foundation.ApplicationModel.Presentation;
using Omniscient.Foundation.Data;
using Omniscient.TimeTracker.Data;
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Omniscient.TimeTracker.Presentation
{
    public class ClientProjectTaskModel : ModelMultiEntitiesBase<Client>
    {
        public ClientProjectTaskModel(EntityList<Client> clients) : base(clients)
        {
        }

        public override bool ContainsEntitiesThatNeedToBeSaved()
        {
            foreach (IEntity entity in Entities)
            {
                if (entity.Status == EntityStatus.New || 
                    entity.Status == EntityStatus.Dirty || 
                    entity.Status == EntityStatus.ToBeDeleted)
                {
                    return true;
                }
            }
            return false;
        }

        public override bool HasEntity(Guid id)
        {
            foreach (IEntity entity in Entities)
            {
                if (entity.Id == id)
                {
                    return true;
                }
            }
            return false;
        }

        public override IEntity GetEntity(Guid id)
        {
            foreach (IEntity entity in Entities)
            {
                if (entity.Id == id)
                {
                    return entity;
                }
            }
            return null;
        }
    }
}
